<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 
            clear 清除浮动（恢复后面元素本来文档流的位置）
        */
        div {
            width: 100px;
            height: 100px;
            border: solid;
        }
        div:nth-child(1) {
            float: left;
        }
        div:nth-child(2) {
            float: right;
        }
        div:nth-child(3) {
            float: left;
        }
        div:nth-child(4) {
            float: right;
        }
        .clear {
            clear: both;
            display: block;
        }
    </style>
</head>
<body>
    <div>1</div>
    <div>2</div>
    <span class="clear"></span>
    <div>3</div>
    <div>4</div>
</body>
</html>